<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>作业3</title>
</head>
<body>
<pre>
    <h1>
         import math
         point = [0, 0]
         action_dict= {'UP': lambda d: [point[0], point[1]+d],
                       'DOWN': lambda d: [point[0], point[1]-d],
                       'LEFT': lambda d: [point[0]-d, point[1]],
                       'RIGHT': lambda d: [point[0]+d, point[1]]
                       }
         while 1:
             action = input('请输入操作:\n')
             if (action == 'STOP'):
                 break
             dire = action.split(' ')[0]
             dist = action.split(' ')[1]
             point=action_dict.get(dire)(int(dist))
         print(point)
         print('距离为:%f'%round(math.sqrt(point[0]**2+point[1]**2)))
    </h1>
</pre>
</body>
</html>